﻿<%@ Page Language="C#" MasterPageFile="~/WebSite/manager.master" AutoEventWireup="true" CodeFile="m_data_UserDetail.aspx.cs" Inherits="WebSite_m_data_UserDetail" Title="无标题页" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
    <style type="text/css">
        .InfoStyle
        {
        	margin:25px auto;
        	width:635px;
        	overflow:visible;
       	}
       	.InfoStyle h1
       	{
       		font-size:20px;
       		background-image:url(../images/Clip.png);
       		background-repeat:no-repeat;
       		width:300px;
       		margin:-23px auto auto 180px;
       		padding-top:15px;
       		padding-left:50px;
       		height:40px;
       	}
       	.InsertBtnStyle
       	{
       		margin:5px 240px auto;
    	    width:90px;
    	    height:30px;
    	    background-color:#669DF0;
    	    font-size:16px;
    	    font-weight:bold;
    	    color:#FFFFFF;
       	}
    </style>
    <div class="InfoStyle">
        <h1>用户注册信息表</h1>
        <br />
        <asp:GridView ID="UserDetailGridView" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="UserId" 
            DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333" GridLines="None" Font-Size="12px" PageSize="20">
            <RowStyle BackColor="#EFF3FB" />
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="UserId" HeaderText="用户ID" ReadOnly="True"  ItemStyle-Width="50px"
                    SortExpression="用户ID" />
                <asp:BoundField DataField="Password" HeaderText="密码"  ControlStyle-Width="50px" ItemStyle-Width="50px"
                    SortExpression="密码" >
<ControlStyle Width="50px"></ControlStyle>
                </asp:BoundField>
                <asp:BoundField DataField="Name" HeaderText="姓名" ItemStyle-Width="60px" ControlStyle-Width="50px" 
                    SortExpression="姓名" >
<ControlStyle Width="50px"></ControlStyle>

<ItemStyle Width="50px"></ItemStyle>
                </asp:BoundField>
                <asp:CheckBoxField DataField="Sex" HeaderText="性别" SortExpression="Sex" />
                <asp:BoundField DataField="Nationality" HeaderText="民族" ControlStyle-Width="50px" ItemStyle-Width="40px"
                    SortExpression="民族" >
<ControlStyle Width="50px"></ControlStyle>
                </asp:BoundField>
                <asp:BoundField DataField="BornDate" HeaderText="出生日期"  
                    ItemStyle-Width="70px" ControlStyle-Width="80px"
                    SortExpression="出生日期" >
<ControlStyle Width="80px"></ControlStyle>

<ItemStyle Width="70px"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="Location" HeaderText="籍贯"  ControlStyle-Width="50px" ItemStyle-Width="50px"
                    SortExpression="籍贯" >
<ControlStyle Width="50px"></ControlStyle>
                </asp:BoundField>
                <asp:BoundField DataField="CollegeName" HeaderText="学院"  ControlStyle-Width="50px" ItemStyle-Width="50px"
                    SortExpression="学院" >
<ControlStyle Width="50px"></ControlStyle>
                </asp:BoundField>
                <asp:BoundField DataField="Grade" HeaderText="年级" ControlStyle-Width="40px" ItemStyle-Width="40px"
                    SortExpression="年级" >
<ControlStyle Width="40px"></ControlStyle>
                </asp:BoundField>
                <asp:BoundField DataField="UserIdentity" HeaderText="用户权限"  ControlStyle-Width="10px" ItemStyle-Width="10px"
                    SortExpression="用户权限" >
<ControlStyle Width="10px"></ControlStyle>
                </asp:BoundField>
                <asp:BoundField DataField="LoginNum" HeaderText="登陆次数" ControlStyle-Width="10px" ItemStyle-Width="15px"
                    SortExpression="登陆次数" >
<ControlStyle Width="10px"></ControlStyle>
                </asp:BoundField>
            </Columns>
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <br />
        <table>
            <tr>
                <td>用户ID</td>
                <td>密码</td>
                <td>姓名</td>
                <td>性别</td>
                <td>民族</td>
                <td>出生日期</td>
                <td>籍贯</td>
                <td>学院</td>
                <td>年级</td>
                <td>用户权限</td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="UserIdTextBox" runat="server" style="width:60px;" 
                        MaxLength="20" EnableViewState="False" Wrap="False"/>
                </td>
                <td>
                    <asp:TextBox ID="UserpwdTextBox" runat="server" style="width:60px;" 
                        MaxLength="20" EnableViewState="False" Wrap="False"/>
                </td>
                <td>
                    <asp:TextBox ID="NameTextBox" runat="server" style="width:60px;" 
                        MaxLength="10" EnableViewState="False" Wrap="False"/>
                </td>
                <td>
                    <asp:DropDownList ID="NationalityDropDownList" runat="server" style="width:60px"  DataSourceID="SqlDataSource3" DataTextField="Nationality" DataValueField="Nationality"/>
                </td>
                <td>
                    <asp:DropDownList ID="SexDropDownList" runat="server">
                        <asp:ListItem Text="男" Value="0" />
                        <asp:ListItem Text="女" Value="1" />
                    </asp:DropDownList>
                </td>
                <td>
                    <asp:TextBox ID="BornDateTextBox" runat="server" style="width:60px;" 
                        EnableViewState="False" Wrap="False" />
                </td>
                <td>
                    <asp:DropDownList ID="CityDropDownList" runat="server" DataSourceID="SqlDataSource2"  DataTextField="CityName" DataValueField="CityName" Width="60px"/>
                </td>
                <td>
                    <asp:DropDownList ID="CollegeDropDownList" runat="server" DataSourceID="XmlDataSource1" DataTextField="College" DataValueField="College" Width="70px"/>
                </td>
                <td>
                    <asp:DropDownList ID="GradeDropDownList" runat="server" DataSourceID="XmlDataSource2" DataTextField="grade" DataValueField="id" Width="45px" />
                </td>
                <td>
                    <asp:DropDownList ID="UserIdentityDropDownList" runat="server">
                        <asp:ListItem Text="学生" Value="0" />
                        <asp:ListItem Text="教师" Value="1" />
                        <asp:ListItem Text="管理员" Value="2" />
                    </asp:DropDownList>
                </td>
           </tr>
        </table>
        <asp:Button ID="InsertBtn" runat="server" Text="插入数据" OnClick="InsertBtn_Click" CssClass="InsertBtnStyle"/>
    </div>
  <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:CSHDBConnectionString %>" 
            SelectCommand="SELECT [UserId], [Password], [Name], [Sex], [Nationality],convert(varchar(10),BornDate,120) as BornDate, [Location], [CollegeName] , [Grade], [UserIdentity], [LoginNum] FROM [UserDetailInfoView]" DeleteCommand="Delete from PhysiqueTest WHERE UserId=@UserId;
Delete from MarkAndLevel UserId=@UserId;
Delete from News WHERE UserId=@UserId;
Delete from Discuss where UserId=@UserId;
Delete from Questionnaire where UserId=@UserId;
Delete from QuestionResults where UserId=@UserId;
Delete from UserDetail where UserId=@UserId;
Delete from UserInfo where UserID=@UserId"  UpdateCommand="update UserDetail
set Name=@Name,Sex=@Sex,Nationality=@Nationality,BornDate=@BornDate,Location=@Location,CollegeName=@CollegeName,Grade=@Grade
where (UserId=@UserId); update UserInfo set Password=@Password,CountNO=@LoginNum,UserIdentity=@UserIdentity where UserId=@UserId;">
            <DeleteParameters>
                <asp:Parameter Name="UserID" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Name" />
                <asp:Parameter Name="Sex" />
                <asp:Parameter Name="Nationality" />
                <asp:Parameter Name="BornDate" />
                <asp:Parameter Name="Location" />
                <asp:Parameter Name="CollegeName" />
                <asp:Parameter Name="Grade" />
                <asp:Parameter Name="UserId" />
                <asp:Parameter Name="Password" />
<asp:Parameter Name="LoginNum"></asp:Parameter>
                <asp:Parameter Name="UserIdentity" />
            </UpdateParameters>
        </asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CSHDBConnectionString %>" 
        
        
        SelectCommand="SELECT LTRIM(RTRIM(CityName)) AS CityName FROM ProvinceTable WHERE CityId=ProvinceId AND CityName!='全部'"></asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CSHDBConnectionString %>" 
        SelectCommand="SELECT LTRIM(RTRIM(Nationality)) AS Nationality FROM NationalityTable"></asp:SqlDataSource>

    <asp:XmlDataSource ID="XmlDataSource1" runat="server" 
        DataFile="~/WebSite/CollegeName.xml" 
        TransformFile="~/WebSite/CollegeName.xslt" 
        XPath="CollegeName/root[position()&gt;1]">
    </asp:XmlDataSource>
    
    <asp:XmlDataSource ID="XmlDataSource2" runat="server" 
        DataFile="~/WebSite/Grade.xml" TransformFile="~/WebSite/Grade.xslt" 
        XPath="SchoolGrade/node[position()&gt;1]">
    </asp:XmlDataSource>


    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
        ControlToValidate="BornDateTextBox" Display="Dynamic" 
        ErrorMessage="请按照yyyy-mm-dd格式输入出生日期" 
        ValidationExpression="^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29))$"></asp:RegularExpressionValidator>
    <asp:Label ID="WarnLabel" runat="server" ForeColor="Red" Visible="false" />    
</asp:Content>

